<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class Rmis extends CCMIS_Controller{

	public function __construct() {
        parent::__construct();
        $this->load->model('rmis/mdl_rmis','research');
    }

	public function index()
	{
		$data = array(
           'page_title' => 'RMIS',
           'message' => ' '
        );
        //if($_SESSION['acc_Type'] == 0)
		//	$this->login();//$this->setup_view('rmis/rmis/LogIn', $data);
		//else
			$this->setup_view('rmis/rmis/home', $data);
	}

	public function LogIn(){
		$data = array(
			'page_title' => 'RMIS',
           'message' => ' '
			);

		if (isset($_POST['btnLogIn'])){

			$uname = strtolower($_POST['txtusername']);
			$pass = $_POST['txtpass'];
			
			$dbdata = $this->research->get_Login_memberdetails($uname);

			if($dbdata != 0 ){

				if($pass == $dbdata[0]['Password']){
					
					$dbdata1 = $this->research->get_Login_research_account($dbdata[0]['MemberID']);
					
					if($dbdata1[0]['Acc_Status'] == 1){
						$this->session->set_userdata('acc_Type',$dbdata1[0]['Acc_Type']);
						$this->setup_view('rmis/rmis/home', $data);
					}
					else {

						$data['message'] = "Please wait for your account to be activated.";
						$this->setup_view('rmis/rmis/LogIn', $data);	
						
					}
				}
				else{
					$data['message'] = "Incorrect password.";
					$this->setup_view('rmis/rmis/LogIn', $data);		
					
				}
			}
			else {
				$data['message'] = "Please acquire an account.";
				$this->setup_view('rmis/rmis/LogIn', $data);			
				
			}
		}
	}
}
?>
